package org.zezs.deployment.config;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.jcraft.jsch.Session;

import java.util.ArrayList;
import java.util.List;

public class Config {
    /** 目前只支持tomcat、springboot  */
    private String type="tomcat";
    private List<TomcatNode> tomcatNodes=new ArrayList<>();
    private List<SpringBootNode> springBootNodes=new ArrayList<>();
    private Nginx nginx;
    private String uploadFile;
    @JSONField(serialize=false)
    private String updateMd5;

    private boolean mustReload;

    private String backPath;
    @JSONField(serialize=false)
    private String backMd5;
    @JSONField(serialize=false)
    private String backFile;

    private SshInfo sshInfo;
    @JSONField(serialize=false)
    private Session session;

    public List<TomcatNode> getTomcatNodes() {
        return tomcatNodes;
    }


    public void setTomcatNodes(List<TomcatNode> tomcatNodes) {
        this.tomcatNodes = tomcatNodes;
    }


    public String getUploadFile() {
        return uploadFile;
    }

    public void setUploadFile(String uploadFile) {
        this.uploadFile = uploadFile;
    }

    public String getBackPath() {
        return backPath;
    }

    public void setBackPath(String backPath) {
        this.backPath = backPath;
    }

    public String getUpdateMd5() {
        return updateMd5;
    }

    public void setUpdateMd5(String updateMd5) {
        this.updateMd5 = updateMd5;
    }

    public String getBackMd5() {
        return backMd5;
    }

    public void setBackMd5(String backMd5) {
        this.backMd5 = backMd5;
    }

    public String getBackFile() {
        return backFile;
    }

    public void setBackFile(String backFile) {
        this.backFile = backFile;
    }

    public boolean isMustReload() {
        return mustReload;
    }

    public void setMustReload(boolean mustReload) {
        this.mustReload = mustReload;
    }

    public static void main(String[] args) {
//        Config config=new Config();
//        config.setBackPath("/root/back");
//        config.setUploadFile("/root/ROOT.war");
//        List<TomcatNode> nodes=new ArrayList<>();
//        SshInfo sshInfo=new SshInfo("172.21.0.5","root","Hwx161275");
//        TomcatNode tomcatNode = new TomcatNode("/usr/local/tomcat9080", "http://127.0.0.1:9080", "http://127.0.0.1:9080/checkTime", "ROOT.war");
//        tomcatNode.setSshInfo(JSON.parseObject(JSONObject.toJSONString(sshInfo),SshInfo.class));
//        TomcatNode tomcatNode2 =new TomcatNode( "/usr/local/tomcat8080", "http://127.0.0.1:8080", "http://127.0.0.1:8080/checkTime", "ROOT.war");
//        tomcatNode2.setSshInfo(JSON.parseObject(JSONObject.toJSONString(sshInfo),SshInfo.class));
//        nodes.add(tomcatNode);
//        nodes.add(tomcatNode2);
//        config.setTomcatNodes(nodes);
//        Nginx nginx = new Nginx();
//        config.setSshInfo(sshInfo);
//        nginx.setConfigFile("/etc/nginx/conf.d/server.conf");
//        config.setNginx(nginx);
//        System.out.println(JSON.toJSONString(config,true));
    }

    public Nginx getNginx() {
        return nginx;
    }

    public void setNginx(Nginx nginx) {
        this.nginx = nginx;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public List<SpringBootNode> getSpringBootNodes() {
        return springBootNodes;
    }

    public void setSpringBootNodes(List<SpringBootNode> springBootNodes) {
        this.springBootNodes = springBootNodes;
    }

    public SshInfo getSshInfo() {
        return sshInfo;
    }

    public void setSshInfo(SshInfo sshInfo) {
        this.sshInfo = sshInfo;
    }

    public Session getSession() {
        return session;
    }

    public void setSession(Session session) {
        this.session = session;
    }
}
